package entitygeneralizationabstractleaf;

import org.eclipse.emf.ecore.EObject;

import org.eclipse.viatra2.emf.incquery.validation.runtime.Constraint;
import org.eclipse.viatra2.emf.incquery.validation.runtime.ValidationUtil;
import org.eclipse.viatra2.emf.incquery.runtime.api.impl.BaseGeneratedMatcherFactory;
import entitygeneralizationabstractleaf.EntityGeneralizationAbstractLeafMatch;
import entitygeneralizationabstractleaf.EntityGeneralizationAbstractLeafMatcherFactory;
import entitygeneralizationabstractleaf.EntityGeneralizationAbstractLeafMatcher;

public class EntityGeneralizationAbstractLeafConstraint extends Constraint<EntityGeneralizationAbstractLeafMatch> {

	private EntityGeneralizationAbstractLeafMatcherFactory matcherFactory;

	public EntityGeneralizationAbstractLeafConstraint() {
		matcherFactory = new EntityGeneralizationAbstractLeafMatcherFactory();
	}

	@Override
	public String getMessage() {
		return "Entity $entity.name$ is at the end of the generalization hierarchy, should not be declared abstract.";
	}

	@Override
	public EObject getLocationObject(EntityGeneralizationAbstractLeafMatch signature) {
		Object location = signature.get("entity");
		if(location instanceof EObject){
			return (EObject) location;
		}
		return null;
	}
	
	@Override
	public int getSeverity() {
		return ValidationUtil.getSeverity("warning");
	}
	
	@Override
	public BaseGeneratedMatcherFactory<EntityGeneralizationAbstractLeafMatch, EntityGeneralizationAbstractLeafMatcher> getMatcherFactory() {
		return matcherFactory;
	}
}
